var app = getApp(),
  $ = require("../../utils/httpHelper.js")
Page({
  data: {
    // tab切换  
    currentTab: 0,
    re_pay:false,
    objarr: [],
    page: 1,
    pagesize: 10,
    totalpage: 0,//最大页数
    height: 0,
    width: 0,
    user_status:'n'
  },
  onLoad: function () {
    var self = this;
    wx.getSystemInfo({
      success: function (res) {
        console.log(res);
        self.setData({ 
          height: res.windowHeight,
          width: res.windowWidth - 20 
        })
      }
    })
    this.getData()
  },
  getData(){
    let params = {
      rd_session: app.globalData.userInfo.rd_session,
      status: this.data.currentTab,
      page: this.data.page,
      page_size: this.data.pagesize
    }
    $.httpPost("class_list", params, (data, err) => {
      this.setData({
        objarr: data.data,
      })
    })
  },
  clicktab(e){
    let tab = e.target.dataset.tab
    if (this.data.currentTab != tab){
      this.setData({
        currentTab: tab,
        page:1
      })
    }
    this.getData()
  },
  imageLoad: function (e) {
    var _this = this;
    var $width = e.detail.width,    //获取图片真实宽度  
      $height = e.detail.height,
      ratio = $width / $height;   //图片的真实宽高比例  
    var viewWidth = this.data.width + 20,           //设置图片显示宽度，  
      viewHeight = this.data.width / ratio;    //计算的高度值     
    this.setData({
      imgwidth: viewWidth,
      imgheight: viewHeight
    })
  },
  toGoods() {
    let status = 'buy'
    wx.navigateTo({
      url: '/pages/goodscat/goodscat?status=' + status,
    })
  },
  todetail(e){
    let id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/pages/kecheng/detail?id='+id,
    })
  }
    
})  